var jwt = require('jsonwebtoken');
var signkey = 'mes_qdhd_mobile_xhykjyxgs';
const setToken = async(uname, uid) => {
  return await jwt.sign({ username: uname, _id: uid }, signkey, { expiresIn: '24h' })
}
const verToken = async(token) => {
  return await jwt.verify(token.split(' ')[1], signkey)
}
module.exports = {
  setToken,
  verToken
}

// exports.setToken = function(username,userid){
//   return new Promise((resolve,reject)=>{
//     const token = jwt.sign({
//       name:username,
//       _id:userid
//     },signkey,{ expiresIn:'1h' });
//     resolve(token);
//   })
// }
// ​
// exports.verToken = function(token){
//   return new Promise((resolve,reject)=>{
//     var info = jwt.verify(token.split(' ')[1],signkey);
//     resolve(info);
//   })
